package com.myassignment.base64;




public class Base64Util {
    private Base64Util() {
    }

    public static String decode(String s) {
        try {
            byte[] src = s.getBytes("UTF-8");
            byte[] dest = Base64.decodeBase64(src);
            return new String(dest, "UTF-8");
        } catch (Throwable e) {
            throw new IllegalStateException(e);
        }
    }

    public static byte[] decode(byte[] src) {
        return Base64.decodeBase64(src);
    }

    public static String encode(String s) {
        try {
            byte[] src = s.getBytes("UTF-8");
            byte[] dest = Base64.encodeBase64(src);
            return new String(dest, "UTF-8");
        } catch (Throwable e) {
            throw new IllegalStateException(e);
        }
    }

    public static byte[] encode(byte[] s) {
        return Base64.encodeBase64(s);
    }
}
